<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Bundler::PubGrub::BasicPackageSource - bundler: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../../Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-all_versions_for">#all_versions_for</a>
    <li ><a href="#method-i-dependencies_for">#dependencies_for</a>
    <li ><a href="#method-i-incompatibilities_for">#incompatibilities_for</a>
    <li ><a href="#method-i-no_versions_incompatibility_for">#no_versions_incompatibility_for</a>
    <li ><a href="#method-i-parse_dependency">#parse_dependency</a>
    <li ><a href="#method-i-root_dependencies">#root_dependencies</a>
    <li ><a href="#method-i-sort_versions_by_preferred">#sort_versions_by_preferred</a>
    <li ><a href="#method-i-versions_for">#versions_for</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Bundler::PubGrub::BasicPackageSource">
    <h1 id="class-Bundler::PubGrub::BasicPackageSource" class="class">
      class Bundler::PubGrub::BasicPackageSource
    </h1>

    <section class="description">
    
<p>Types:</p>

<p>Where possible, <a href="../PubGrub.html"><code>Bundler::PubGrub</code></a> will accept user-defined types, so long as they quack.</p>

<p>## “Package”:</p>

<p>This class will be used to represent the various packages being solved for. .to_s will be called when displaying errors and debugging info, it should probably return the package’s name. It must also have a reasonable definition of == and hash</p>

<p>Example classes: String (“rails”)</p>

<p>## “Version”:</p>

<p>This class will be used to represent a single version number.</p>

<p>Versions don’t need to store their associated package, however they will only be compared against other versions of the same package.</p>

<p>It must be Comparible (and implement &lt;=&gt; reasonably)</p>

<p>Example classes: Gem::Version, Integer</p>

<p>## “Dependency”</p>

<p>This class represents the requirement one package has on another. It is returned by <a href="BasicPackageSource.html#method-i-dependencies_for"><code>dependencies_for</code></a>(package, version) and will be passed to <a href="BasicPackageSource.html#method-i-parse_dependency"><code>parse_dependency</code></a> to convert it to a format <a href="../PubGrub.html"><code>Bundler::PubGrub</code></a> understands.</p>

<p>It must also have a reasonable definition of ==</p>

<p>Example classes: String (“~&gt; 1.0”), <a href="../../Gem/Requirement.html"><code>Gem::Requirement</code></a></p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
  <span class="ruby-ivar">@root_package</span> = <span class="ruby-constant">Package</span>.<span class="ruby-identifier">root</span>
  <span class="ruby-ivar">@root_version</span> = <span class="ruby-constant">Package</span>.<span class="ruby-identifier">root_version</span>

  <span class="ruby-ivar">@cached_versions</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@root_package</span>
      <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [<span class="ruby-ivar">@root_version</span>]
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">all_versions_for</span>(<span class="ruby-identifier">k</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@sorted_versions</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-ivar">@cached_versions</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">sort</span> }
  <span class="ruby-ivar">@version_indexes</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-ivar">@cached_versions</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">each</span>.<span class="ruby-identifier">with_index</span>.<span class="ruby-identifier">to_h</span> }

  <span class="ruby-ivar">@cached_dependencies</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">packages</span>, <span class="ruby-identifier">package</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">package</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@root_package</span>
      <span class="ruby-identifier">packages</span>[<span class="ruby-identifier">package</span>] = {
        <span class="ruby-ivar">@root_version</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">root_dependencies</span>
      }
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">packages</span>[<span class="ruby-identifier">package</span>] = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">versions</span>, <span class="ruby-identifier">version</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">versions</span>[<span class="ruby-identifier">version</span>] = <span class="ruby-identifier">dependencies_for</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">version</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-all_versions_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">all_versions_for</span><span
                                class="method-args">(package)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override me!</p>

<p>This is called per package to find all possible versions of a package.</p>

<p>It is called at most once per-package</p>

<p>Returns: Array of versions for a package, in preferred order of selection</p>

                              <div class="method-source-code" id="all_versions_for-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 49</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">all_versions_for</span>(<span class="ruby-identifier">package</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-dependencies_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dependencies_for</span><span
                                class="method-args">(package, version)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override me!</p>

<p>Returns: Hash in the form of { package =&gt; requirement, … }</p>

                              <div class="method-source-code" id="dependencies_for-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dependencies_for</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">version</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-incompatibilities_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">incompatibilities_for</span><span
                                class="method-args">(package, version)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="incompatibilities_for-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 137</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">incompatibilities_for</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">version</span>)
  <span class="ruby-identifier">package_deps</span> = <span class="ruby-ivar">@cached_dependencies</span>[<span class="ruby-identifier">package</span>]
  <span class="ruby-identifier">sorted_versions</span> = <span class="ruby-ivar">@sorted_versions</span>[<span class="ruby-identifier">package</span>]
  <span class="ruby-identifier">package_deps</span>[<span class="ruby-identifier">version</span>].<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dep_package</span>, <span class="ruby-identifier">dep_constraint_name</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">low</span> = <span class="ruby-identifier">high</span> = <span class="ruby-identifier">sorted_versions</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">version</span>)

    <span class="ruby-comment"># find version low such that all &gt;= low share the same dep</span>
    <span class="ruby-keyword">while</span> <span class="ruby-identifier">low</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span>
        <span class="ruby-identifier">package_deps</span>[<span class="ruby-identifier">sorted_versions</span>[<span class="ruby-identifier">low</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]][<span class="ruby-identifier">dep_package</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">dep_constraint_name</span>
      <span class="ruby-identifier">low</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">low</span> =
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">low</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
        <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">sorted_versions</span>[<span class="ruby-identifier">low</span>]
      <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># find version high such that all &lt; high share the same dep</span>
    <span class="ruby-keyword">while</span> <span class="ruby-identifier">high</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">sorted_versions</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&amp;&amp;</span>
        <span class="ruby-identifier">package_deps</span>[<span class="ruby-identifier">sorted_versions</span>[<span class="ruby-identifier">high</span>]][<span class="ruby-identifier">dep_package</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">dep_constraint_name</span>
      <span class="ruby-identifier">high</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">high</span> =
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">high</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sorted_versions</span>.<span class="ruby-identifier">length</span>
        <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">sorted_versions</span>[<span class="ruby-identifier">high</span>]
      <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">range</span> = <span class="ruby-constant">VersionRange</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">min:</span> <span class="ruby-identifier">low</span>, <span class="ruby-value">max:</span> <span class="ruby-identifier">high</span>, <span class="ruby-value">include_min:</span> <span class="ruby-keyword">true</span>)

    <span class="ruby-identifier">self_constraint</span> = <span class="ruby-constant">VersionConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">package</span>, <span class="ruby-value">range:</span> <span class="ruby-identifier">range</span>)

    <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@packages</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">dep_package</span>)
      <span class="ruby-comment"># no such package -&gt; this version is invalid</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">dep_constraint</span> = <span class="ruby-identifier">parse_dependency</span>(<span class="ruby-identifier">dep_package</span>, <span class="ruby-identifier">dep_constraint_name</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dep_constraint</span>
      <span class="ruby-comment"># falsey indicates this dependency was invalid</span>
      <span class="ruby-identifier">cause</span> = <span class="ruby-constant">Bundler</span><span class="ruby-operator">::</span><span class="ruby-constant">PubGrub</span><span class="ruby-operator">::</span><span class="ruby-constant">Incompatibility</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidDependency</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dep_package</span>, <span class="ruby-identifier">dep_constraint_name</span>)
      <span class="ruby-keyword">return</span> [<span class="ruby-constant">Incompatibility</span>.<span class="ruby-identifier">new</span>([<span class="ruby-constant">Term</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">self_constraint</span>, <span class="ruby-keyword">true</span>)], <span class="ruby-value">cause:</span> <span class="ruby-identifier">cause</span>)]
    <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dep_constraint</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">VersionConstraint</span>)
      <span class="ruby-comment"># Upgrade range/union to VersionConstraint</span>
      <span class="ruby-identifier">dep_constraint</span> = <span class="ruby-constant">VersionConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dep_package</span>, <span class="ruby-value">range:</span> <span class="ruby-identifier">dep_constraint</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-constant">Incompatibility</span>.<span class="ruby-identifier">new</span>([<span class="ruby-constant">Term</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">self_constraint</span>, <span class="ruby-keyword">true</span>), <span class="ruby-constant">Term</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dep_constraint</span>, <span class="ruby-keyword">false</span>)], <span class="ruby-value">cause:</span> <span class="ruby-value">:dependency</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-no_versions_incompatibility_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">no_versions_incompatibility_for</span><span
                                class="method-args">(_package, unsatisfied_term)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="no_versions_incompatibility_for-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 131</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">no_versions_incompatibility_for</span>(<span class="ruby-identifier">_package</span>, <span class="ruby-identifier">unsatisfied_term</span>)
  <span class="ruby-identifier">cause</span> = <span class="ruby-constant">Incompatibility</span><span class="ruby-operator">::</span><span class="ruby-constant">NoVersions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">unsatisfied_term</span>)

  <span class="ruby-constant">Incompatibility</span>.<span class="ruby-identifier">new</span>([<span class="ruby-identifier">unsatisfied_term</span>], <span class="ruby-value">cause:</span> <span class="ruby-identifier">cause</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parse_dependency" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse_dependency</span><span
                                class="method-args">(package, dependency)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override me!</p>

<p>Convert a (user-defined) dependency into a format <a href="../PubGrub.html"><code>Bundler::PubGrub</code></a> understands.</p>

<p><a href="Package.html"><code>Package</code></a> is passed to this method but for many implementations is not needed.</p>

<p>Returns: either a <a href="VersionRange.html"><code>Bundler::PubGrub::VersionRange</code></a>, <a href="VersionUnion.html"><code>Bundler::PubGrub::VersionUnion</code></a>, or a</p>

<pre class="ruby"><span class="ruby-constant">Bundler</span><span class="ruby-operator">::</span><span class="ruby-constant">PubGrub</span><span class="ruby-operator">::</span><span class="ruby-constant">VersionConstraint</span>
</pre>

                              <div class="method-source-code" id="parse_dependency-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_dependency</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">dependency</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-root_dependencies" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">root_dependencies</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override me!</p>

<p>If not overridden, this will call <a href="BasicPackageSource.html#method-i-dependencies_for"><code>dependencies_for</code></a> with the root package.</p>

<p>Returns: Hash in the form of { package =&gt; requirement, … } (see <a href="BasicPackageSource.html#method-i-dependencies_for"><code>dependencies_for</code></a>)</p>

                              <div class="method-source-code" id="root_dependencies-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">root_dependencies</span>
  <span class="ruby-identifier">dependencies_for</span>(<span class="ruby-ivar">@root_package</span>, <span class="ruby-ivar">@root_version</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sort_versions_by_preferred" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">sort_versions_by_preferred</span><span
                                class="method-args">(package, sorted_versions)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override me (maybe)</p>

<p>If not overridden, the order returned by <a href="BasicPackageSource.html#method-i-all_versions_for"><code>all_versions_for</code></a> will be used</p>

<p>Returns: Array of versions in preferred order</p>

                              <div class="method-source-code" id="sort_versions_by_preferred-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 87</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sort_versions_by_preferred</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">sorted_versions</span>)
  <span class="ruby-identifier">indexes</span> = <span class="ruby-ivar">@version_indexes</span>[<span class="ruby-identifier">package</span>]
  <span class="ruby-identifier">sorted_versions</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">version</span><span class="ruby-operator">|</span> <span class="ruby-identifier">indexes</span>[<span class="ruby-identifier">version</span>] }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-versions_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">versions_for</span><span
                                class="method-args">(package, range=VersionRange.any)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="versions_for-source">
            <pre><span class="ruby-comment"># File bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb, line 119</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">versions_for</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">range</span>=<span class="ruby-constant">VersionRange</span>.<span class="ruby-identifier">any</span>)
  <span class="ruby-identifier">versions</span> = <span class="ruby-identifier">range</span>.<span class="ruby-identifier">select_versions</span>(<span class="ruby-ivar">@sorted_versions</span>[<span class="ruby-identifier">package</span>])

  <span class="ruby-comment"># Conditional avoids (among other things) calling</span>
  <span class="ruby-comment"># sort_versions_by_preferred with the root package</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">versions</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
    <span class="ruby-identifier">sort_versions_by_preferred</span>(<span class="ruby-identifier">package</span>, <span class="ruby-identifier">versions</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">versions</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

